/* 
    多了previous指针,tail指向最后节点
*/
function DoublyLinkedList() {
  function Node(data) {
    this.data = data;
    this.prev = null;
    this.next = null;
  }

  this.head = null;
  this.tail = null;
  this.length = 0;

  // 1.append方法
  DoublyLinkedList.prototype.append = (data) => {
    let newNode = new Node(data);

    if (this.length === 0) {
      this.head = newNode;
      this.tail = newNode;
    } else {
      newNode.prev = this.tail;
      this.tail.next = newNode;
      this.tail = newNode;
    }
    this.length++;
  };
  // 2.
  // 3.
  // 4.
  // 5.
}
